package com.lh.createBean;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class MyRefelct {

    public static void main(String[] args)  {
        try {
            Student student = Student.class.newInstance();
            System.out.println("通过放射创建bean"+student);
            refelct01();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

    }

    public static void refelct01(){

        try {
            Class<Student> aClass = Student.class;
            Constructor<?>[] constructors = aClass.getDeclaredConstructors();
            Student student = (Student) constructors[0].newInstance();
            System.out.println("通过放射创建bean"+student);
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

    }
}
